package com.ming.yygh.hosp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ming.yygh.common.exception.HospitalException;
import com.ming.yygh.common.result.Result;
import com.ming.yygh.common.result.ResultCodeEnum;
import com.ming.yygh.hosp.mapper.HospitalSetMapper;
import com.ming.yygh.hosp.service.HospitalSetService;
import com.ming.yygh.model.hosp.HospitalSet;
import com.ming.yygh.vo.order.SignInfoVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author Light
 * @date 2021/11/15 15:16
 */
@Service
public class HospitalSetServiceImpl extends ServiceImpl<HospitalSetMapper, HospitalSet> implements HospitalSetService {

    @Override
    public SignInfoVo getSignInfoVo(String hoscode) {
        HospitalSet hospitalSet = baseMapper.selectOne(new QueryWrapper<HospitalSet>().eq("hoscode", hoscode));
        if (null == hospitalSet) {
            throw new HospitalException(ResultCodeEnum.HOSPITAL_OPEN);
        }
        SignInfoVo signInfoVo = new SignInfoVo();
        signInfoVo.setApiUrl(hospitalSet.getApiUrl());
        signInfoVo.setSignKey(hospitalSet.getSignKey());
        return signInfoVo;
    }
}
